from django.db import models

# Create your models here.

# 患者信息表
class patientinformation(models.Model):
    sex_choice = (
        (1, '男'),
        (2, '女'),
    )
    name = models.CharField(max_length=50, verbose_name='姓名', null=True)
    age = models.IntegerField(verbose_name='年龄', null=True)
    sex = models.CharField(max_length=2, verbose_name='性别', choices=sex_choice, null=True)
    phone = models.CharField(max_length=11, verbose_name='手机号', null=True)

    class Meta:
        db_table = 'patientinformation'

# 地址表
class address(models.Model):
    address = models.CharField(max_length=100, verbose_name='省')
    city = models.CharField(max_length=100, verbose_name='市')
    District = models.CharField(max_length=100, verbose_name='区')
    detailadd = models.CharField(max_length=200, verbose_name='详细地址')

    class Meta:
        db_table = 'address'

# 就诊人信息表
class Usersview(models.Model):
    phone = models.CharField(max_length=11, verbose_name='电话')
    pwd = models.CharField(max_length=200, verbose_name='密码')
    gesture_password = models.CharField(max_length=100, verbose_name='手势密码', null=True, blank=True)
    avatat = models.CharField(verbose_name='头像', max_length=200, default='https://iknow-pic.cdn.bcebos.com/b21c8701a18b87d6a90deb81150828381e30fde5')
    # 外键
    user_message = models.ForeignKey(to=patientinformation, on_delete=models.CASCADE, verbose_name='用户',null=True)
    address_message = models.ForeignKey(to=address, on_delete=models.CASCADE, verbose_name='地址',null=True)

    class Meta:
        db_table = 'Usersview'


# 医生表
class Doctor(models.Model):
    sex_choice = (
        (1, '男'),
        (2, '女'),
    )
    name = models.CharField(max_length=200, verbose_name='姓名')
    age = models.CharField(max_length=50, verbose_name='年龄')
    sex = models.CharField(max_length=10, verbose_name='性别', choices=sex_choice)
    title = models.CharField(max_length=200, verbose_name='职称')
    department = models.CharField(max_length=100, verbose_name='科室')

    class Meta:
        db_table = 'Doctor'

# 医院信息表
class HospitalInfo(models.Model):
    cla = (
        (1, '综合医院'),
        (2, '专科医院'),
    )
    department = models.CharField(max_length=200, verbose_name='科室')
    grade = models.CharField(max_length=200, verbose_name='等级')
    classes = models.CharField(max_length=200, verbose_name='类别', choices=cla)
    doctor_a = models.ForeignKey(to=Doctor, on_delete=models.CASCADE, verbose_name='医生')


    class Meta:
        db_table = 'HospitalInfo'


# 陪诊师信息表
class PatientEscort(models.Model):
    sex_choice = (
        (1, '男'),
        (2, '女'),
    )
    name = models.CharField(max_length=50, verbose_name='姓名')
    age = models.IntegerField(verbose_name='年龄')
    sex = models.IntegerField(choices=sex_choice, verbose_name='性别')
    phone = models.CharField(max_length=11, verbose_name='电话')
    add = models.CharField(max_length=200, verbose_name='地址')
    favorable_rate = models.FloatField(verbose_name='好评率')
    state = models.CharField(verbose_name='状态', max_length=50)
    takeOrders = models.IntegerField(verbose_name='接单数')

    class Meta:
        db_table = 'PatientEscort'

# 陪诊师的服务项目
class PatientEscortService(models.Model):
    inHospitalEscort = models.BooleanField(verbose_name='项目分类', default=False)
    service = models.CharField(max_length=50, verbose_name='业务')
    price = models.FloatField(verbose_name='价格')
    serviceSpecification = models.CharField(max_length=200, verbose_name='服务说明')

    class Meta:
        db_table = 'PatientEscortService'

# 订单信息表（基类）
class OrderInformation(models.Model):
    hospital = models.ForeignKey(to=HospitalInfo, on_delete=models.CASCADE, verbose_name='医院')
    escort = models.ForeignKey(to=PatientEscort, on_delete=models.CASCADE, verbose_name='陪诊师')
    patient = models.ForeignKey(to=Usersview, on_delete=models.CASCADE, verbose_name='患者')
    coupon = models.FloatField(verbose_name='优惠券', null=True, blank=True)
    datum = models.CharField(verbose_name='资料(病例)可选', null=True, blank=True, max_length=200)
    noyes = models.CharField(verbose_name='是否同意协议', max_length=100)
    price = models.FloatField(verbose_name='价格')
    state = models.CharField(verbose_name='状态', max_length=50)

    class Meta:
        db_table = 'OrderInformation'

# 送取结果订单表
class SendTheResultOrder(OrderInformation):
    receive_information = models.CharField(verbose_name='收件信息', max_length=200)
    Report_information = models.CharField(verbose_name='报告信息', max_length=200)
    times = models.DateTimeField(verbose_name='时间')

# 代办问诊表
class ConsultOnBehalfOf(OrderInformation):
    department = models.ForeignKey(to=HospitalInfo, on_delete=models.CASCADE, verbose_name='科室')
    doctor = models.CharField(verbose_name='医生', max_length=100)
    times = models.DateTimeField(verbose_name='时间')

# 陪诊订单表
class EscortOrder(OrderInformation):
    department = models.ForeignKey(to=HospitalInfo, on_delete=models.CASCADE, verbose_name='科室')
    times = models.DateTimeField(verbose_name='时间')
    pickup = models.CharField(verbose_name='接诊信息', max_length=200)

# 代办买药表
class BuyMedicineOnBehalfOf(OrderInformation):
    drug = models.CharField(verbose_name='药品', max_length=100)
    add = models.CharField(verbose_name='送货地址', max_length=200)
    times = models.DateTimeField(verbose_name='时间')

# 诊前约号表
class Diagnose(OrderInformation):
    department = models.ForeignKey(to=HospitalInfo, on_delete=models.CASCADE, verbose_name='科室')
    doctor = models.CharField(verbose_name='医生', max_length=50)
    times = models.DateTimeField(verbose_name='时间')

